package cn.tanghom.content.controller.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.tanghom.content.model.Dashboard;
import cn.tanghom.content.model.Report;
import cn.tanghom.content.repository.ReportRepository;
import cn.tanghom.support.hook.DashboardModule;
import cn.tanghom.support.web.BaseController;


@Controller
@RequestMapping("report")
public class ReportController extends BaseController<Report> {
	ReportRepository reportRepository;
	
	DashboardModule<Report> plugin = new DashboardModule<Report>("report"){

    	//加载统计项，根据主报表，加载同一时期的其他报表，进行聚合计算
    	@Override
    	public boolean loadModel(Dashboard dash){		
    		Report report = reportRepository.findOne(dash.getCid());
    		if(report!=null){
    			dash.setContent(report.getName()+":"+report.getValue());
    		}
    		return false;
    	}
    	
    };
}
